package com.ruoyi.web.controller.websocket;


import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.teaching.domain.WebSocketTemporaryMessage;
import com.ruoyi.teaching.service.WebSocketTemporaryMessageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 李志鑫
 * @since 2024-09-10
 */
@RestController
@RequestMapping("/webSocketTemporaryMessage")
@Api(tags = "webSocket-临时消息")
public class WebSocketTemporaryMessageController {
    @Autowired
    private WebSocketTemporaryMessageService webSocketTemporaryMessageService;

    /**
     * 查询临时消息
     */
//    @PreAuthorize("@ss.hasPermi('platform:course:list')")
    @GetMapping("/list")
    @ApiOperation(value = "获取临时消息", notes = "获取自己的临时消息")
    public AjaxResult list(Integer pageNum, Integer pageSize) {
        return webSocketTemporaryMessageService.getTemporaryMessageList(pageNum,pageSize);
    }

    @GetMapping("/listByUserId")
    @ApiOperation(value = "获取聊天框临时消息", notes = "获取聊天框临时消息")
    public AjaxResult listByUserId(Integer userId) {
        return webSocketTemporaryMessageService.listByUserId(userId);
    }


    /**
     * 发送临时消息
     */
//    @PreAuthorize("@ss.hasPermi('platform:course:list')")
    @PostMapping("/add")
    @ApiOperation(value = "发送临时消息", notes = "发送临时消息、只能发送5次，一人5次（包括回复）")
    public AjaxResult add(@RequestBody WebSocketTemporaryMessage webSocketTemporaryMessage) {
        return webSocketTemporaryMessageService.getTemporaryMessageAdd(webSocketTemporaryMessage);
    }


}

